Skip to content

(report) Add TX_CURR report#32

Merged
ibacher merged 8 commits intopath-drc:mainfrom
reagan-meant:rt-27
Sep 5, 2025
Merged

(report) Add TX_CURR report#32
ibacher merged 8 commits intopath-drc:mainfrom
reagan-meant:rt-27

Conversation

@reagan-meant
Copy link
Copy Markdown
Contributor

No description provided.

AND e_subsequent.voided = 0
AND et_subsequent.uuid = 'cb0a65a7-0587-477e-89b9-cf2fd144f1d4'
AND DATE(e_subsequent.encounter_datetime) > DATE(o_appt.value_datetime)
AND DATE(e_subsequent.encounter_datetime) <= :onOrBefore
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure they received drugs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add logic that queries patients seen in the reporting period who were given drugs

List<Concept> artInitiationAnswers = new ArrayList<Concept>();
artInitiationAnswers.add(cs.getConceptByUuid("1256AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")); // Start ART
artInitiationAnswers.add(cs.getConceptByUuid("162904AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")); // Restart ART
artInitiation.setValueList(artInitiationAnswers);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure they have drugs given

List<Concept> transferInPMTCTAnswers = new ArrayList<Concept>();
transferInPMTCTAnswers.add(cs.getConceptByUuid("160563AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")); // Transfer in
transferInPMTCTAnswers.add(cs.getConceptByUuid("163532AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")); // Enroll into PMTCT
transferInPMTCT.setValueList(transferInPMTCTAnswers);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure they have drugs given

WHERE o_prevention.encounter_id = o.encounter_id
AND o_prevention.voided = 0
AND c_prevention.uuid = '163532AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' -- ART Prevention being taken
AND o_prevention.value_coded IS NOT NULL
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This answer should be "Yes"

@reagan-meant reagan-meant requested a review from ibacher August 20, 2025 12:27
Copy link
Copy Markdown
Contributor

@ibacher ibacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @reagan-meant! A few questions, but mostly small quibbles about SQL...

import org.openmrs.module.reporting.common.BooleanOperator;

@Component
public class DRCTx_CurrReportManager extends ActivatedReportManager {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we probably just name this DRCTxCurrReportManager?

Comment on lines +13 to +14
AND o.value_numeric IS NOT NULL
AND o.value_numeric < 90
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically o.value_numeric < 90 will also eliminate rows where value_numeric is null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQL uses a 3-value logic where things are TRUE, FALSE and NULL that uses something like these truth tables:

Value NOT Value
True False
False True
Null Null
Value AND True AND False AND Null
True True False Null
False False False Null
Null Null Null Null
Value OR True OR False OR Null
True True True Null
False True False Null
Null Null Null Null

Basically, any operation that involves a NULL results in a NULL, and NULL is not true, so the row isn't matched.

Comment on lines +13 to +14
AND o.value_numeric IS NOT NULL
AND o.value_numeric > 180
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be >=?

Comment on lines +16 to +17
AND DATE(o.obs_datetime) >= :onOrAfter
AND DATE(o.obs_datetime) <= :onOrBefore
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AND DATE(o.obs_datetime) >= :onOrAfter
AND DATE(o.obs_datetime) <= :onOrBefore
AND DATE(o.obs_datetime) BETWEEN :onOrAfter AND :onOrBefore

Comment on lines +217 to +222
// Not stopped ART in date range
SqlCohortDefinition notStoppedARTSqlCD = new SqlCohortDefinition();
String notStoppedARTSql = getStringFromResource("org/openmrs/module/drcreports/sql/DRCTxCurrNotStopedART.sql");
notStoppedARTSqlCD.setQuery(notStoppedARTSql);
notStoppedARTSqlCD.addParameter(new Parameter("onOrAfter", "On Or After", Date.class));
notStoppedARTSqlCD.addParameter(new Parameter("onOrBefore", "On Or Before", Date.class));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this account for the case where in one quarter, a person initiates ART, discontinues ART and then recontinues it before the end date?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See Appendix J of the MERS Reference Guide

notTransferredOutSqlCD.addParameter(new Parameter("onOrAfter", "On Or After", Date.class));
notTransferredOutSqlCD.addParameter(new Parameter("onOrBefore", "On Or Before", Date.class));

// Lessthan 3 months ART Dispensation
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Lessthan 3 months ART Dispensation
// Less than 3 months ART Dispensation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DRCTxCurrNotStoppedART.sql 👉 DRCTxCurrNotStoppedART.sql

@reagan-meant reagan-meant requested a review from ibacher August 21, 2025 12:37
@ibacher
Copy link
Copy Markdown
Contributor

ibacher commented Aug 21, 2025

Could we add some test cases for this since it's kind of key we get this right. I think the tests should cover:

  • At least 1 patient for each disaggregation category
  • The described cases from Appendix J, specifically (I've reworded this so that each scenario is a separate patient history):
    • Patient A was newly initiated on treatment. During the reporting period, Patient A did not attend an appointment and had no clinical contact for 28 days after that appointment. Patient A was then contacted and came in for an appointment. At the end of the reporting period, Patient A is on treatment (Patient A shows up on TX_CURR)
    • Patients B started the reporting period on treatment, but all did not attend an appointment and had no clinical contact for 28 days afterwards. Patient B was successfully contacted and came in for an appointment. At the end of the quarter, Patient B is on treatment (Patient B shows up on TX_CURR)
    • Patients C started the reporting period on treatment, but all did not attend an appointment and had no clinical contact for 28 days afterwards. Patient C was not successfully contacted and did not come in for an appointment. At the end of the quarter, Patient C is not on treatment (Patient C does not show up in TX_CURR)
    • Patients D started the reporting period not on treatment. Patient CDwas contacted and came in for an appointment but experienced an interruption in treatment again during the reporting period. By the end of the reporting period, Patients D is not on treatment (Patient D does not show up in TX_CURR)

${project.parent.artifactId}.report.drc.fifteenYrsAndAboveMales.label=15+ years (Males)
${project.parent.artifactId}.report.drc.fifteenYrsAndAboveFemales.label=15+ years (Females)

${project.parent.artifactId}.report.drc.threeMonthsDrugsGiven.label=3 months drugs
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we change the label here to "3 months or less" and similarly in French.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is actually less than 3 months, fixed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor things:

  1. Could we name this simlarly to the report manager itself, i.e., DRCTxCurrTestDataset
  2. Why is the dataset split into two?

@ibacher
Copy link
Copy Markdown
Contributor

ibacher commented Sep 3, 2025

Hmmm... It seems the test fails now?

@ibacher ibacher merged commit a266588 into path-drc:main Sep 5, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants